from die import Die
from plotly.graph_objs import Bar, Layout
from plotly import offline

die = Die()
die_1 = Die()
die_2 = Die(10)
results = []
for roll_num in range(50_000):
    results.append(die_1.roll() + die_2.roll())

frequencies = []

max_result = die_1.num_sides + die_2.num_sides + 1
for value in range(2, max_result):
    frequencies.append(results.count(value))

x_values = list(range(2, max_result))
data = [Bar(x=x_values, y=frequencies)]

x_axis_config = {'title': '结果', 'dtick': 1}
y_axis_config = {'title': '结果的频率'}

my_layout = Layout(title='掷一个D6和 一个D10 50 000次的结果',
                   xaxis=x_axis_config, yaxis=y_axis_config)

offline.plot({'data': data, 'layout': my_layout}, filename='d6.html')
